﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Reflection;

namespace OpenMinded.DALFactory
{
    /// <summary>
    /// 此类用于实现抽象工厂模式去创建从配置文件指定的数据访问层的实例
    /// </summary>
    public sealed class DataAccess
    {
        // 查找我们将要使用的数据访问层
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
        //private static readonly string orderPath = ConfigurationManager.AppSettings["OrdersDAL"];
        public DataAccess() { }
        #region 创建Users类实例
        /// <summary>
        /// 实现CreateUsers()方法，用于创建Users类实例
        /// </summary>
        /// <returns></returns>
        public static OpenMinded.IDAL.IUsers CreateUsers()
        {
            string className = path + ".Users";
            return (OpenMinded.IDAL.IUsers)Assembly.Load(path).CreateInstance(className);
        } 
        #endregion


    }
}
